<?php

namespace app\common\validate;

use think\Validate;

class UserLevel extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'name'        => 'require|length:2,50',
        'image'       => 'require',
        'description' => 'max:255',
        'price'       => 'require|float|>=:0',
        'flag'        => 'max:30',
        'status'      => 'require|in:normal,hidden'
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'name.require'    => '等级名称不能为空',
        'name.length'     => '等级名称长度必须在2-50个字符之间',
        'description.max' => '等级描述最多255个字符',
        'price.require'   => '等级价格不能为空',
        'price.float'     => '等级价格必须是数字',
        'price.>='        => '等级价格不能小于0',
        'flag.max'        => '等级标识最多30个字符',
        'status.require'  => '状态不能为空',
        'status.in'       => '状态值不正确'
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['name', 'image', 'price', 'flag', 'status'],
        'edit' => ['name', 'image', 'price', 'flag', 'status']
    ];
}